﻿Imports System
Imports System.Collections.Generic
Imports System.IO
Imports System.Linq
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Controls.Primitives
Imports System.Windows.Data
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Navigation

Partial Public Class UserBlogItem
    Inherits UserControl

    Public Sub New()
        Me.InitializeComponent()
    End Sub

    Public Async Function LoadSongTitleAsync() As Task
        Try
            Dim keyword = CType(Me.DataContext, Blog).SongKeyword
            Dim id = CType(Me.DataContext, Blog).SongID
            If String.IsNullOrEmpty(keyword) Or String.IsNullOrEmpty(id) Then
                'MessageBox.Show("获取歌曲信息失败：歌曲信息为空")
                Return
            End If
            Dim _client As New HttpClientBase()
            Dim response = Await _client.GetAsync(Of Song)(String.Format("vdm/api/music/song/{0}/{1}", keyword, id))
            If response.Code <> 200 Then
                'MessageBox.Show("获取歌曲信息失败:" + response.Message)
                Return
            End If
            TB_SongTitle.Text = response.Data.Title
        Catch ex As Exception
            Console.WriteLine(ex.Message)
            Console.WriteLine(ex.StackTrace)
            MessageBox.Show("系统错误：" & ex.Message)
            NavigationService.Navigate(NavigationData.LOGIN_PAGE_URI)
        End Try
    End Function

End Class
